<?php
require('includes/top.php');

$user = $_POST['user_name'];
$password = $_POST['password'];

$query  = "SELECT * FROM users where user_name='".trim($user)."'";
$result = mysql_query($query);
if(mysql_num_rows($result)!="")
{
while($row = mysql_fetch_assoc($result))
{
if(trim($password)==trim($row['user_password']))
{
$_SESSION['user_id']= $row['user_id'];
$_SESSION['user_groups_id']= $row['user_groups_id'];
$_SESSION['user_no']= $row['user_no'];
$_SESSION['user_firstname']= $row['user_firstname'];
$_SESSION['user_lastname']= $row['user_lastname'];
$_SESSION['	user_telno']= $row['user_telno'];
$_SESSION['user_address']= $row['user_address'];
$_SESSION['	user_email_address']= $row['user_email_address'];
$_SESSION['user_password']= $row['user_password'];
$_SESSION['user_name']= $row['user_name'];




if($_SESSION['user_groups_id']=='1')
{
header('Location:view_status.php');
}


if($_SESSION['user_groups_id']=='2')
{
header('Location:request_laptop_main.php');
}
 
if($_SESSION['user_groups_id']=='3')
{
header('Location:view_request_main.php');
}
 
 
if($_SESSION['user_groups_id']=='4')
{
header('Location:view_approved_main.php');
}


if($_SESSION['user_groups_id']=='6')
{
header('Location:approve_replacement.php');
}

if($_SESSION['user_groups_id']=='7')
{
header('Location:admin_main.php');
}


if($_SESSION['user_groups_id']=='8')
{
header('Location:view_repair_list_main.php');
}

 
 } 
 else
 {
 header('Location:index.php?er=1');
 }
 }
}
else
{
 header('Location:index.php?er=2');
}
?>